<template>
  <div class="topNav" v-bind:class="{ hideNav: show }">
    <div class="logo">
      <img
        v-if="
          domain2 === 'https://218.13.22.89' ||
          domain2 === 'https://hezhangzhi.gd-gy.com.cn'
        "
        src="../../../static/img/logo_01.png"
        height="40"
        width="364"
        alt=""
      />
      <img v-else src="../../../static/img/logo_01.png" alt="" />
    </div>
    <div class="chref">
      <span class="chref_span" v-if="chref1"
        >河长界面<span @click="back" v-if="chref1" class="changeSpan">返回</span
        ><span
          @click="changeWork"
          class="changeSpan"
          v-if="changeSpan && chref1"
          ><img
            style="vertical-align: middle; margin-right: 5px"
            src="./img/change.svg"
            alt=""
          />切换</span
        ></span
      >
      <span class="chref_span" v-if="chrefs"
        >河长办界面<span
          @click="changeWork"
          class="changeSpan"
          v-if="changeSpan && chrefs"
          ><img
            style="vertical-align: middle; margin-right: 5px"
            src="./img/change.svg"
            alt=""
          />切换</span
        ></span
      >
    </div>
    <div class="user">
      <Badge
        @click.native="showVideo"
        style="margin-right: 30px"
        title="视频会议"
      >
        <Icon type="md-people" size="26"></Icon>
      </Badge>
      <Badge
        :count="parseInt(count)"
        style="margin-right: 30px"
        @click.native="showTask"
        title="指令"
      >
        <Icon type="ios-notifications-outline" size="26"></Icon>
      </Badge>
      <Badge @click.native="showNatice" title="通知">
        <Icon type="ios-mail-outline" size="26"></Icon>
      </Badge>
      <span class="touxiang">
        <Avatar :src="head" @click.native="showUser" style="margin-top: 2px" />
      </span>
      <p
        style="
          position: absolute;
          top: -10px;
          left: 70%;
          width: 100px;
          z-index: 9999;
        "
        id="cherfName"
      >
        <template>
          <Dropdown @on-click="aa" trigger="hover">
            <a href="javascript:void(0)" style="color: white">
              {{ username }}
              <Icon type="md-arrow-dropdown" style="color: white"></Icon>
            </a>
            <DropdownMenu slot="list">
              <DropdownItem name="man">个人信息</DropdownItem>
              <!-- <DropdownItem name="examine">考核评分</DropdownItem> -->
              <DropdownItem v-if="work1" name="collect">公文收藏</DropdownItem>
              <DropdownItem name="logout">注销</DropdownItem>
            </DropdownMenu>
          </Dropdown>
        </template>
      </p>

      <p style="position: absolute; top: 10px; left: 70%">{{ position }}</p>
    </div>
    <div class="menu" v-if="!work">
      <Menu mode="horizontal" theme="dark" active-name="1" @on-select="clickFn">
        <MenuItem name="work" v-if="work">
          <img
            src="../../../static/img/home/work.png"
            height="30"
            width="30"
            alt=""
          />
          工作台
        </MenuItem>
        <MenuItem name="chose" v-if="chose">
          <img
            src="../../../static/img/home/work.png"
            height="30"
            width="30"
            alt=""
          />
          工作台
        </MenuItem>
        <MenuItem name="work1" v-if="work1">
          <img
            src="../../../static/img/home/work.png"
            height="30"
            width="30"
            alt=""
          />
          工作台
        </MenuItem>
        <MenuItem name="data">
          <img
            src="../../../static/img/home/data.png"
            height="30"
            width="30"
            alt=""
          />
          业务管理
        </MenuItem>
        <MenuItem name="multiple">
          <img
            src="../../../static/img/home/zonghe.png"
            height="30"
            width="30"
            alt=""
          />
          系统管理
        </MenuItem>
      </Menu>
    </div>
    <Modal v-model="taskModal" title="指令" width="800">
      <Tabs @on-click="changeTask">
        <TabPane label="新建指令" name="新建指令">
          <Form :model="modelItem" :label-width="80">
            <i-col span="12">
              <Form-item label="接受人部门" prop="receive_username">
                <Cascader
                  :data="areaArr"
                  placeholder="请选择部门"
                  v-model="area"
                ></Cascader>
              </Form-item>
            </i-col>
            <i-col span="12">
              <Form-item label="接受人" prop="receive_username">
                <Select v-model="modelItem.receive_username" clearable>
                  <OptionGroup
                    :label="v.rolename"
                    :key="v._id"
                    v-for="v in receiveData"
                  >
                    <Option
                      v-for="item in v.users"
                      :value="item.username"
                      :key="item.username"
                      >{{ item.realname }}</Option
                    >
                  </OptionGroup>
                </Select>
              </Form-item>
            </i-col>
            <i-col span="24">
              <Form-item label="主题" prop="task_title">
                <Input
                  v-model="modelItem.task_title"
                  :maxlength="16"
                  placeholder="请输入主题"
                ></Input>
              </Form-item>
              <Form-item label="内容" prop="task_content">
                <Input
                  v-model="modelItem.task_content"
                  :maxlength="500"
                  placeholder="请输入内容"
                ></Input>
              </Form-item>
              <Form-item>
                <Button type="info" @click="sendTask">发送指令</Button>
              </Form-item>
            </i-col>
          </Form>
        </TabPane>
        <TabPane label="收到指令" name="收到指令">
          <Table
            ref="table"
            :data="taskData"
            :columns="taskColumns"
            stripe
          ></Table>
          <Page
            class="pull-right dingwei"
            :total="Page.total"
            :current="Page.current"
            size="small"
            show-total
            @on-change="changePage"
          ></Page>
        </TabPane>
        <TabPane label="已发送指令" name="已发送指令">
          <Table
            ref="table"
            :data="taskData"
            :columns="taskColumns2"
            stripe
          ></Table>
          <Page
            class="pull-right dingwei"
            :total="Page.total"
            :current="Page.current"
            size="small"
            show-total
            @on-change="changePage"
          ></Page>
        </TabPane>
      </Tabs>
    </Modal>
    <Modal v-model="videoModal" @on-ok="goVideo" title="视频会议">
      <Form :model="videoItem" :label-width="60">
        <Form-item label="视频方式" prop="type">
          <Select v-model="videoItem.type" clearable>
            <Option value="0">新建房间</Option>
            <Option value="1">进入房间</Option>
          </Select>
        </Form-item>
        <Form-item label="房间名" prop="room_name">
          <Input
            v-model="videoItem.room_name"
            :maxlength="20"
            placeholder="请输入房间名"
          ></Input>
        </Form-item>
      </Form>
    </Modal>
    <Modal v-model="userModal" title="用户信息">
      <Tabs v-model="tabActive" @on-click="changeUser">
        <TabPane label="修改信息" name="修改信息">
          <Form :model="userItem" :label-width="60">
            <Form-item label="用户名" prop="realname">
              <Input
                v-model="userItem.realname"
                :maxlength="20"
                placeholder="请输入用户名"
              />
            </Form-item>
            <Form-item label="手机号" prop="phone">
              <Input
                v-model="userItem.phone"
                :maxlength="20"
                placeholder="请输入手机号"
              />
            </Form-item>
            <Form-item label="邮箱" prop="email">
              <Input
                type="email"
                v-model="userItem.email"
                :maxlength="40"
                placeholder="请输入邮箱"
              />
            </Form-item>
            <Form-item label="在职位置" prop="position">
              <Input
                v-model="userItem.position"
                :maxlength="20"
                placeholder="请输入在职位置"
              />
            </Form-item>
          </Form>
        </TabPane>
        <!-- <TabPane label="修改密码" name="修改密码">
          <Form :model="userItem" :rules="rules" :label-width="100" ref="Jform">
            <Form-item label="原密码" prop="oldpwd">
              <Input
                type="password"
                v-model="userItem.oldpwd"
                :maxlength="20"
                placeholder="请输入原密码"
              ></Input>
            </Form-item>
            <Form-item label="新密码" prop="newpwd">
              <Input
                type="password"
                v-model="userItem.newpwd"
                :maxlength="20"
                placeholder="请输入新密码"
              ></Input>
            </Form-item>
            <Form-item label="再次填写新密码" prop="newpwd2">
              <Input
                type="password"
                v-model="userItem.newpwd2"
                :maxlength="20"
                placeholder="请再次输入新密码"
              ></Input>
            </Form-item>
          </Form>
        </TabPane> -->
      </Tabs>
      <div slot="footer">
        <Button v-if="btnSave" type="primary" @click="changeMessage"
          >修改信息</Button
        >
        <!-- <Button v-if="!btnSave" type="primary" @click="changepwd"
          >修改密码</Button
        > -->
        <Button @click="userModal = false">取消</Button>
      </div>
    </Modal>
    <Modal
      v-model="tipModal"
      :mask-closable="false"
      :closable="false"
      title="系统提示"
    >
      <div>您的密码依然为系统初始密码，请及时修改，防止账号被盗用</div>
      <div style="text-align: center" slot="footer">
        <Button type="primary" @click="showPwd">立即修改</Button>
      </div>
    </Modal>
    <Modal
      v-model="pwdModal"
      :mask-closable="false"
      :closable="false"
      title="修改密码"
    >
      <Form :model="userItem" :rules="rules" :label-width="100">
        <Form-item label="原密码" prop="oldpwd">
          <Input
            type="password"
            v-model="userItem.oldpwd"
            :maxlength="20"
            placeholder="请输入原密码"
          ></Input>
        </Form-item>
        <Form-item label="新密码" prop="newpwd">
          <Input
            type="password"
            v-model="userItem.newpwd"
            :maxlength="20"
            placeholder="请输入新密码"
          ></Input>
        </Form-item>
        <Form-item label="再次填写新密码" prop="newpwd2">
          <Input
            type="password"
            v-model="userItem.newpwd2"
            :maxlength="20"
            placeholder="请再次输入新密码"
          ></Input>
        </Form-item>
      </Form>
      <div slot="footer">
        <Button type="primary" @click="changepwd">修改密码</Button>
      </div>
    </Modal>
    <!-- 考核评分已去除 by lxn 2021-0303 -->
    <!-- <examine-modal ref="examineModal" /> -->
  </div>
</template>


<script>
import { ajaxPost } from 'global/axios';
import { domain2 } from 'global/setting';
import storage from 'good-storage';
import examineModal from 'base/examine-modal/examineModal';
import md5 from 'md5';
export default {
  components: {
    'examine-modal': examineModal,
  },
  data () {
    const valideRePassword = (rule, value, callback) => {
      if (value !== this.userItem.newpwd) {
        callback(new Error('两次输入密码不一致'))
      } else {
        callback()
      }
    }
    return {
      urlTaskList: '/law/task/list',
      urlTaskEdit: '/law/task/edit',
      urlTaskNew: '/law/task/new',
      urlCount: '/law/task/count',
      urlReceiveUser: '/sys/userinfo/list',
      urlTreeList: '/sys/department/getTree',
      urlUserList: '/sys/userinfo/findbyrole',
      urlVideoNew: '/bus/video/new',
      urlChangePwd: '/sys/userinfo/changepsw',
      urlChangeMessgae: '/sys/userinfo/editMy',
      urlLogout: '/sys/userinfo/logout',
      tipModal: false,
      domain2,
      rules: {
        oldpwd: [
          { required: true, message: '原密码不能为空', trigger: 'blur' },
        ],
        newpwd: [
          { required: true, message: '密码不能为空', trigger: 'blur' },
          {
            validator (rule, value, callback, source, options) {
              let reg = /^(?=.*\d)(?=.*[a-zA-Z])(?=.*[.~!?@#\-\+\=\_$%^&*])[\da-zA-Z~.!?@#\-\+\=\_$%^&*]{8,16}$/;
              // let complexReg = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@!%*#?&_])[A-Za-z\d$@$!%*#?&]{8,}$/; // 复杂度校验
              if (value.length < 8) {
                callback(new Error('密码不能少于8位'));
              } else if (value.length > 16) {
                callback(new Error('密码不能大于16位'));
              } else if (!reg.test(value)) {
                callback(new Error('密码中至少包含数字、字母和符号'));
                // } else if (!complexReg.test(value)) {
                //   callback(new Error('你的密码强度太低, 请修改'));
              } else {
                callback();
              }
            },
            trigger: 'blur',
          },
        ],
        newpwd2: [
          { required: true, message: '密码不能为空', trigger: 'blur' },
          {
            validator (rule, value, callback, source, options) {
              let reg = /^(?=.*\d)(?=.*[a-zA-Z])(?=.*[.~!?@#\-\+\=\_$%^&*])[\da-zA-Z~.!?@#\-\+\=\_$%^&*]{8,16}$/;
              // let complexReg = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@!%*#?&_])[A-Za-z\d$@$!%*#?&]{8,}$/; // 复杂度校验
              if (value.length < 8) {
                callback(new Error('密码不能少于8位'));
              } else if (value.length > 16) {
                callback(new Error('密码不能大于16位'));
              } else if (!reg.test(value)) {
                callback(new Error('密码中至少包含数字、字母和符号'));
                // } else if (!complexReg.test(value)) {
                //   callback(new Error('你的密码强度太低, 请修改'));
              } else {
                callback();
              }
            },
            trigger: 'blur',
          },
          { validator: valideRePassword, trigger: 'blur' }
        ],
      },
      show: false,
      btnSave: true,
      pwdModal: false,
      username: '',
      position: '',
      head: '',
      count: '',
      taskModal: false,
      userModal: false,
      userItem: {},
      taskData: [],
      taskColumns: [
        {
          title: '发送人',
          key: 'send_realname',
        },
        {
          title: '主题',
          key: 'task_title',
        },
        {
          title: '内容',
          key: 'task_content',
        },
        {
          title: '时间',
          key: 'send_time',
        },
        {
          title: '操作',
          render: (h, params) => {
            if (params.row.is_send == '0') {
              return h(
                'Button',
                {
                  props: {
                    type: 'primary',
                    size: 'small',
                  },
                  on: {
                    click: () => {
                      this.comfirmTask(params.row);
                    },
                  },
                },
                '确认收到'
              );
            } else {
              return '已收到';
            }
          },
        },
      ],
      taskColumns2: [
        {
          title: '接受人',
          key: 'receive_username',
        },
        {
          title: '主题',
          key: 'task_title',
        },
        {
          title: '内容',
          key: 'task_content',
        },
        {
          title: '时间',
          key: 'send_time',
        },
      ],
      modelItem: {},
      saveType: '',
      Page: {
        current: 1,
        pageSize: 10,
        total: 0,
      },
      savePage: '',
      areaArr: [],
      area: [],
      receiveData: [],
      personnel: '',
      chref: '',
      receive_realname: '',
      chref1: false,
      chrefs: false,
      work: false,
      work1: false,
      chose: false,
      changeSpan: false,
      videoModal: false,
      videoItem: {
        type: '',
        room_name: '',
      },
      tabActive: '修改信息'
    };
  },
  methods: {
    back () {
      this.$router.push('/home/work');
    },
    changeWork () {
      let str = this.$router.history.current.fullPath;
      if (str == '/home/work') {
        this.chref1 = false;
        this.chrefs = true;
        this.$router.push('/home/work1');
      } else if (str == '/home/work1') {
        this.chref1 = true;
        this.chrefs = false;
        this.$router.push('/home/work');
      }
    },
    aa (name) {
      if (name === 'logout') {
        this.logout();
      } else if (name === 'man') {
        this.showUser();
      } else if (name === 'collect') {
        this.$router.push({
          path: '/home/data/document',
          query: { type: '收藏' },
        });
        // 考核评分已去除 by lxn 2021-0303
        // } else {
        //   this.$refs.examineModal.show();
      }
    },
    logoutFuc () { // 退出登录调用此接口
      let params = {
        data: {},
        url: this.urlLogout,
        token: storage.session.get('token'),
        success: res => { },
      };
      ajaxPost(params);
    },
    logout () {
      if (storage.session.get('isOtherLoginType') === true) {
        let { origin } = window.location
        let backurl = `${origin}/hzSystem/logout`
        window.location.href = `
        https://xtbg.gdzwfw.gov.cn/zwrz/rz/sso/logout?client_id=zwrz_fshzzgl&backurl=${encodeURIComponent(backurl)}
        `
      }
      storage.remove('token');
      storage.remove('realname');
      storage.remove('roles');
      storage.remove('userid');
      storage.remove('username');
      storage.remove('position');
      storage.remove('head');
      storage.remove('level');
      storage.remove('dep_name');
      this.logoutFuc();
      this.$router.push('/login');
    },
    clickFn (name) {
      if (name == 'chose') {
        this.$router.push(`/${name}`);
      } else {
        this.$router.push(`/home/${name}`);
      }
    },
    hiddeNav () {
      this.show = true;
    },
    getCount () {
      let params = {
        data: {
          is_send: '0',
          receive_username: storage.session.get('username'),
        },
        url: this.urlCount,
        token: storage.session.get('token'),
        success: res => {
          this.$Loading.finish();
          this.count = res.data.result;
        },
      };
      ajaxPost(params);
    },
    getTask (name, page) {
      this.saveType = name;
      let params = {
        data: {
          page: 1,
          pageSize: 10,
          searchValue: {},
          order: { send_time: -1 },
        },
        url: this.urlTaskList,
        token: storage.session.get('token'),
        success: res => {
          this.taskData = res.data.result.result;
          this.Page.total = res.data.result.totalSize;
        },
      };
      if (typeof page === 'string' || typeof page === 'number') {
        params.data.page = parseInt(page);
      }
      if (name === '收到指令') {
        params.data.searchValue.tab = 'receive';
      }
      if (name === '已发送指令') {
        params.data.searchValue.tab = 'send';
      }
      ajaxPost(params);
    },
    showTask () {
      this.taskModal = true;
      let str = this.$router.history.current.fullPath;
      if (str == '/home/data/wechat' || str == '/home/data/document') {
        $('.ivu-tabs-tab:eq(3)').html('新建指令');
      } else if (
        str == '/functional-dep' ||
        str == '/home/multiple/user' ||
        str == '/home/multiple/gate-pump'
      ) {
        $('.ivu-tabs-tab:eq(2)').html('新建指令');
        $('.ivu-tabs-tab:eq(3)').html('收到指令');
        $('.ivu-tabs-tab:eq(4)').html('已发送指令');
      } else if (str == '/home/chief-wechat') {
        $('.ivu-tabs-tab:eq(3)').html('新建指令');
        $('.ivu-tabs-tab:eq(4)').html('收到指令');
        $('.ivu-tabs-tab:eq(5)').html('已发送指令');
      } else if (str == '/home/data/directories') {
        $('.ivu-tabs-tab:eq(4)').html('新建指令');
        $('.ivu-tabs-tab:eq(5)').html('收到指令');
        $('.ivu-tabs-tab:eq(6)').html('已发送指令');
      } else {
        $('.ivu-tabs-tab:eq(0)').html('新建指令');
        $('.ivu-tabs-tab:eq(1)').html('收到指令');
        $('.ivu-tabs-tab:eq(2)').html('已发送指令');
      }
    },
    changeTask (name) {
      if (name === '新建指令') {
        $('.ivu-tabs').css('height', '280px');
      } else {
        $('.ivu-tabs').css('height', 'auto');
        this.getTask(name);
      }
    },
    changePage (page) {
      this.getTask(this.saveType, page);
      this.savePage = page;
    },
    comfirmTask (row) {
      let date = new Date().format('yyyy-MM-dd hh:mm:ss');
      row.receive_time = date;
      row.is_send = '1';
      let params = {
        data: row,
        url: this.urlTaskEdit,
        token: storage.session.get('token'),
        success: res => {
          if (res.data.code == '0000') {
            this.getCount();
            this.getTask(this.saveType, this.savePage);
            this.$Message.success({
              content: '确认成功',
            });
          } else {
            this.$Message.warning({
              content: res.data.message,
            });
          }
        },
      };
      ajaxPost(params);
    },
    getReceive (dep) {
      let params = {
        data: {
          dep_name: dep,
        },
        url: this.urlUserList,
        token: storage.session.get('token'),
        success: res => {
          this.$Loading.finish();
          this.receiveData = res.data.result;
        },
      };
      ajaxPost(params);
    },
    sendTask () {
      let params = {
        data: {
          receive_username: this.modelItem.receive_username,
          receive_realname: this.receive_realname,
          task_title: this.modelItem.task_title,
          task_content: this.modelItem.task_content,
        },
        url: this.urlTaskNew,
        token: storage.session.get('token'),
        success: res => {
          if (res.data.code == '0000') {
            this.$Loading.finish();
            this.$Message.success({
              content: '发送成功',
            });
            this.area = [];
            this.modelItem.receive_username = '';
            this.modelItem.task_title = '';
            this.modelItem.task_content = '';
          } else {
            this.$Message.warning({
              content: res.data.message,
            });
          }
        },
      };
      ajaxPost(params);
    },
    getAddress () {
      let params = {
        data: {},
        url: this.urlTreeList,
        token: storage.session.get('token'),
        success: res => {
          this.areaArr = res.data.result;
        },
      };
      ajaxPost(params);
    },
    showNatice () {
      let type = storage.session.get('type');
      if (type === '0' || type === '1' || type === '2') {
        this.$router.push('/home/chref-notice');
      } else if (
        type === '4' ||
        type === '3' ||
        type === '6' ||
        type === '7' ||
        type === '8'
      ) {
        this.$router.push('/home/data/notice');
      }
    },
    showVideo () {
      this.videoModal = true;
      this.videoItem = {
        type: '',
        room_name: '',
      };
    },
    goVideo () {
      if (this.videoItem.type === '0') {
        let params = {
          data: {
            room_name: this.videoItem.room_name,
            swuid: storage.session.get('userid'),
          },
          url: this.urlVideoNew,
          token: storage.session.get('token'),
          success: res => {
            if (res.data.code == '0000') {
              this.$Loading.finish();
              this.$Message.success({
                content: '新建成功',
              });
              this.$router.push('/video');
              storage.session.set('room_name', this.videoItem.room_name);
            } else {
              this.$Message.warning({
                content: res.data.message,
              });
            }
          },
        };
        ajaxPost(params);
      } else if (this.videoItem.type === '1') {
        storage.session.set('room_name', this.videoItem.room_name);
        this.$router.push('/video');
      }
    },
    showUser () {
      this.userModal = true;
      this.userItem = {
        oldpwd: '',
        newpwd2: '',
        newpwd: '',
        email: '',
        position: '',
        phone: '',
        realname: '',
      };
    },
    changeUser (data) {
      if (data === '修改密码') {
        this.btnSave = false;
      } else {
        this.btnSave = true;
      }
    },
    changepwd () {

      this.$refs.Jform.validate(valid => {
        if (valid) {
          let params = {
            data: {
              username: storage.session.get('username'),
              oldpsw: md5(this.userItem.oldpwd),
              newpsw: md5(this.userItem.newpwd),
            },
            url: this.urlChangePwd,
            token: storage.session.get('token'),
            success: res => {
              if (res.data.code == '0000') {
                storage.session.set('isInitPwd', false);
                this.$Message.success({
                  content: '修改成功',
                });
                this.userModal = false;
                this.pwdModal = false;
                setTimeout(() => {
                  this.$Message.info({
                    content: '修改完密码请重新登录',
                  });
                  setTimeout(() => {
                    this.logout();
                  }, 2000);
                }, 2000);
              } else {
                this.$Message.warning({
                  content: res.data.message,
                });
              }
            },
          };
          ajaxPost(params);
        }
      })
    },
    changeMessage () {
      let params = {
        data: {},
        url: this.urlChangeMessgae,
        token: storage.session.get('token'),
        success: res => {
          if (res.data.code == '0000') {
            this.$Message.success({
              content: '修改成功',
            });
            this.userModal = false;
            setTimeout(() => {
              this.$Message.info({
                content: '修改完个人信息请重新登录',
              });
              setTimeout(() => {
                this.logout();
              }, 2000);
            }, 2000);
          } else {
            this.$Message.warning({
              content: res.data.message,
            });
          }
        },
      };
      if (this.userItem.realname !== '') {
        params.data.realname = this.userItem.realname;
      }
      if (this.userItem.email !== '') {
        params.data.email = this.userItem.email;
      }
      if (this.userItem.position !== '') {
        params.data.position = this.userItem.position;
      }
      if (this.userItem.phone !== '') {
        params.data.phone = this.userItem.phone;
      }
      ajaxPost(params);
    },
    showPwd () {
      this.tipModal = false;
      this.pwdModal = true;
    },
  },
  mounted () {
    let str = this.$router.history.current.fullPath;
    if (
      str == '/home/work' ||
      str == '/home/ceshi' ||
      str == '/home/chref-patrol' ||
      str == '/home/chref-major' ||
      str == '/home/chref-notice'
    ) {
      this.chref1 = true;
      this.chrefs = false;
    } else if (str == '/home/work1') {
      this.chref1 = false;
      this.chrefs = true;
    } else if (str == '/chose') {
      this.chref1 = false;
      this.chrefs = true;
    }
    this.getAddress();
    this.getReceive();
    this.getCount();
    this.head = domain2 + storage.session.get('head');
    this.username = storage.session.get('realname');
    this.position = storage.session.get('position');
    let type = storage.session.get('type');
    if (type == '0' || type == '1' || type == '2' || type === '9') {
      this.work = true;
      this.work1 = false;
      this.chose = false;
    } else if (type == '3' || type === '6') {
      this.work = false;
      this.work1 = false;
      this.chose = true;
    } else if (type == '4' || type == '7' || type == '8') {
      this.work = false;
      this.work1 = true;
      this.chose = false;
    }
    // 后台人员反馈不知edit_pwd是何作用，因与现判断初始密码冲突，遂注释 --2021/06/03
    // if (storage.session.get('edit_pwd') === '1') {
    //   this.tipModal = true;
    // }
    // 如果是初始化密码，显示修改密码弹窗
    if (storage.session.get('isInitPwd')) {
      this.userModal = true;
      this.tabActive = '修改密码';
      this.btnSave = false;
    }
  },
  created () {
    this.$bus.on('hideTopNav', this.hiddeNav);
    let type = storage.session.get('type');
    if (type === '3' || type === '6') {
      this.changeSpan = true;
    } else {
    }
  },
  beforeDestroy () {
    this.$bus.off('hideTopNav', this.hiddeNav);
  },
  watch: {
    area (data) {
      let i = data.length - 1;
      this.getReceive(data[i]);
    },
    'modelItem.receive_username' (data) {
      this.receiveData.map(item => {
        if (data == item.username) {
          this.receive_realname = item.realname;
        }
      });
    },
  },
};
</script>
<style lang="less">
.topNav {
  width: 100%;
  float: left;
  background: url('../../../static/img/top_bg_01.png');
  background-size: cover;

  .logo {
    float: left;
    width: 20%;
    height: 40px;
    line-height: 40px;
    color: #fff;

    img {
      width: 100%;
      vertical-align: middle;
    }
  }
  .chref {
    float: left;

    .chref_span {
      display: inline-block;
      height: 40px;
      line-height: 40px;
      font-size: 16px;
      font-weight: bold;
      color: #fdd158;
      margin-left: 10px;

      .changeSpan {
        display: inline-block;
        padding: 0 10px;
        font-size: 14px;
        border-radius: 5px;
        height: 36px;
        margin-top: 2px;
        color: #fff;
        margin-left: 10px;
        cursor: pointer;
        background: linear-gradient(to right, #0072ff, #37b9ff);
      }
      .changeSpan:hover {
        color: #fdd158;
      }
    }
  }
  .menu {
    width: 33%;
    float: right;
    height: 40px;

    img {
      vertical-align: middle !important;
    }
    .ivu-menu {
      background: none;
    }
  }
  .user {
    width: 401px;
    float: right;
    color: white;
    height: 40px;
    line-height: 40px;
    position: relative;

    .touxiang {
      border-left: 1px solid white;
      display: inline-block;
      padding-left: 40px;
      margin-left: 40px;
      height: 40px;
      line-height: 40px;
      vertical-align: middle;
    }
  }
  .ivu-menu-horizontal {
    line-height: 40px;
  }
}
.hideNav {
  display: none;
}
.ivu-tabs .ivu-select-group-wrap ul {
  margin: 0;
}
</style>
